package shenxinfu;

/**
 * @author xizizzz
 * @description: TODO
 * @date 2021-8-31下午 04:15
 */
public class Test1 {

    public int[] nearestDiff(int[] nums) {
        int[] res = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            int x = 0, y = 0;
            for (int j = i - 1; j >= 0; j--) {
                if (nums[j] < nums[i]) {
                    x = nums[j];
                    break;
                }
            }
            for (int j = i + 1; j < nums.length; j++) {
                if (nums[j] > nums[i]) {
                    y = nums[j];
                    break;
                }
            }
            res[i] = y - x;
        }
        return res;
    }
}
